﻿using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenCVInfras;
public class PaintCrossLineService
{
    public static Mat PaintCrossLine(int[] p, OpenCvSharp.Size size)
    {
        var mat = new Mat(size.Height,size.Width, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));

        if (p[0] < 0 || p[1] < 0) return mat;

        Cv2.Line(mat, 0, p[1], p[0], p[1],new Scalar(Color.Blue.B, Color.Blue.G, Color.Blue.R,200));
        Cv2.Line(mat, p[0], 0, p[0], p[1],new Scalar(Color.Blue.B, Color.Blue.G, Color.Blue.R,200));

        Cv2.Line(mat, p[0], p[1], size.Width, p[1], new Scalar(Color.Blue.B, Color.Blue.G, Color.Blue.R,200));
        Cv2.Line(mat, p[0], p[1], p[0], size.Height, new Scalar(Color.Blue.B, Color.Blue.G, Color.Blue.R,200));

        return mat;
    }

    public static bool IsPointIsValid(int[] p, OpenCvSharp.Size size)
    {
        if (p[0]>0 && p[0]<=size.Width && p[1]>0 && p[1]<=size.Height) return true;

        return false;
    }
}
